package com.qinghong.blog.config;

import com.qinghong.blog.enums.ResultCode;
import com.qinghong.blog.exception.BaseException;
import com.qinghong.blog.vo.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.sql.SQLException;
import java.sql.SQLIntegrityConstraintViolationException;

/**
 * 全局异常处理
 */
@RestControllerAdvice
public class GlobalException {

    @ExceptionHandler(BaseException.class)
    public Result mySqlException(BaseException e){
        return Result.error(ResultCode.GLOBAL_ERROR);
    }
}
